<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:p="http://primefaces.org/ui"
      xmlns:f="http://java.sun.com/jsf/core">
    <h:head>
        <title>Turneador Recaudo</title>
        <link rel="stylesheet" href="resources/css/styles.css"/>
    </h:head>
    <h:body>
        <h:outputLink id="loginLink" value="javascript:void(0)" onclick="dlg.show()" title="Iniciar Sesión">     
            <p:graphicImage id="centrar" value="/resources/img/login_button.png" />  
        </h:outputLink>  
  
        <p:growl id="growl" showDetail="true" life="3000" />  
  
        <p:dialog id="dialog" header="Iniciar Sesión" widgetVar="dlg" modal="true">  
             
            <h:form>
                
                <h:panelGrid columns="2" cellpadding="5">  
                    
                    <h:outputLabel for="Usuario" value="Username:" />  
                    <p:inputText value="#{loginBean.usuario.logUsua}"   
                            id="Usuario" required="true" label="username" />  

                    <h:outputLabel for="Contraseña" value="Password:" />  
                    <h:inputSecret value="#{loginBean.usuario.pswUsua}"   
                            id="Contraseña" required="true" label="password" />  

                    <f:facet name="footer">  
                        <p:commandButton id="loginButton" value="Ingresar" update=":growl"   
                            actionListener="#{loginBean.login}"   
                            oncomplete="handleLoginRequest(xhr, status, args)"/>  
                    </f:facet>
                    
                </h:panelGrid>  

            </h:form>  
            
        </p:dialog>  
  
<script type="text/javascript">  
    function handleLoginRequest(xhr, status, args) {  
        if(args.validationFailed || !args.loggedIn) {  
            jQuery('#dialog').effect("shake", { times:3 }, 100);  
        } else {  
            dlg.hide();  
            jQuery('#loginLink').fadeOut();  
            window.location = "/turningsoft/index.rolvar";
        }  
    }  
</script>  
    </h:body>
</html>

